package com.xique.park.service.biz.service.impl;

import com.xique.common.core.utils.SecurityUtils;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.park.bean.domain.ParkLane;
import com.xique.park.bean.vo.comm.LaneVo;
import com.xique.park.service.biz.service.IParkLaneBizService;
import com.xique.park.service.service.IParkLaneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class ParkLaneBizServiceImpl implements IParkLaneBizService {

    @Autowired
    private IParkLaneService parkLaneService;

    @Override
    public AjaxResult getParkLaneList() {
        ParkLane parkLane = new ParkLane();
        parkLane.setParkId(SecurityUtils.getParkId());
        List<ParkLane> list = parkLaneService.selectParkLaneList(parkLane);
        Map<String, Object> map = new HashMap<>(1);
        List<LaneVo> vos = list.stream().map(result -> {
            LaneVo vo = new LaneVo();
            vo.setLaneId(result.getId());
            vo.setLaneName(result.getName());
            vo.setLaneType(result.getLaneType());
            return vo;
        }).collect(Collectors.toList());
        map.put("list", vos);
        return AjaxResult.success(map);
    }
}
